import ajax from './request.config'

/**
 * 登录
 * @param {loginname,passwd} param0 
 */
export const login = ({
    loginname,
    passwd
}) => ajax.post('/application/login', {
    loginname,
    passwd
})


/**
 * 流程管理
 */
//设备维修
export const getRepaireTableData = ({
    orderNumber,
    province,
    city,
    district,
    state,
    customerUuid,
    warningOvertime,
    pro_uuid,
    startTime,
    endTime,
    instuuid,
    pageSize,
    pageNumber
}) => ajax.post('/warningmanage/list', {
    orderNumber,
    province,
    city,
    district,
    state,
    customerUuid,
    warningOvertime,
    pro_uuid,
    startTime,
    endTime,
    instuuid,
    pageSize,
    pageNumber
})

//新增报修单
export const saveRepaire = ({
    name,
    mobile,
    province,
    city,
    district,
    customerUuid,
    instUuid,
    code,
    faultTypeUuid,
    describe,
    equip_uuid
}) => ajax.post('/warningmanage/save', {
    name,
    mobile,
    province,
    city,
    district,
    customerUuid,
    instUuid,
    code,
    faultTypeUuid,
    describe,
    equip_uuid
})

//分配转介接口
export const saveFPZJ = ({
        uuid,
        candidate,
        content
    }) => ajax.post('/warningmanage/update', {
        uuid,
        candidate,
        content
    })
    //撤回
export const revokeReapire = uuid => ajax.post('/warningmanage/revoke', { uuid })
    //撤销
export const cancleRepaire = uuid => ajax.post('/warningmanage/cancle', { uuid })
    //完成
export const completeRepaire = uuid => ajax.post('/warningmanage/complete', { uuid })


//场地巡检
export const getInspecTableData = ({
        code,
        province,
        city,
        district,
        state,
        customerUuid,
        progressState,
        startTime,
        endTime,
        inst_uuid,
        pageSize,
        pageNumber
    }) => ajax.post('/inspection/list ', {
        code,
        province,
        city,
        district,
        state,
        customerUuid,
        progressState,
        startTime,
        endTime,
        inst_uuid,
        pageSize,
        pageNumber
    })
    //新增场地巡检
export const saveInspection = ({
        inst_uuid,
        inst_name,
        item_uuid,
        candidate,
        remark,
        time_to_use,
    }) => ajax.post('/inspection/preservation', {
        inst_uuid,
        inst_name,
        item_uuid,
        candidate,
        remark,
        time_to_use,
    })
    //更换联系人
export const changeContact = ({
        contactMobile,
        contactName,
        uuid
    }) => ajax.post('/inspection/updateContacts', {
        contactMobile,
        contactName,
        uuid
    })
    //场地分配转介接口
export const saveInspecFP = ({
        uuid,
        candidate,
        remark
    }) => ajax.post('/inspection/saveDistribute', {
        uuid,
        candidate,
        remark
    })
    //撤回
export const revokeInspection = uuid => ajax.post('/inspection/revoke', { uuid })
    //撤销
export const cancleInspection = uuid => ajax.post('/inspection/closed', { uuid })

//办公用品
export const getGoodsTable = ({
    orderNumber,
    startTime,
    endTime,
    city,
    province,
    state,
    district,
    inst_uuid,
    pageSize,
    pageNumber,
    customerUuid
}) => ajax.post('/goodsOrder/list', {
    orderNumber,
    startTime,
    endTime,
    city,
    province,
    state,
    district,
    inst_uuid,
    pageSize,
    pageNumber,
    customerUuid
})

export const sendMail = uuid => ajax.post('/goodsOrder/sendMail', { uuid })

//凭证请领
export const getVoucherTable = ({
    orderNumber,
    startTime,
    endTime,
    city,
    province,
    state,
    district,
    inst_uuid,
    pageSize,
    pageNumber,
    customerUuid
}) => ajax.post('/voucherApply/list ', {
    orderNumber,
    startTime,
    endTime,
    city,
    province,
    state,
    district,
    inst_uuid,
    pageSize,
    pageNumber,
    customerUuid
})
export const voucherSendMail = uuid => ajax.post('/voucherApply/sendMail', { uuid })

//应急响应
export const changeUgStatus = ({
    uuid,
    status,
    content
}) => ajax.post('/urgent/editStatus', {
    uuid,
    status,
    content
})

export const saveurgent = ({
    uuid,
    customer_uuid,
    inspection_uuid,
    title,
    content,
    group_uuid
}) => ajax.post('/urgent/save', {
    uuid,
    customer_uuid,
    inspection_uuid,
    title,
    content,
    group_uuid
})

//BANNER
export const saveBanner = ({ name, url, image_url, uuid, flag }) => ajax.post('/banner/save', { name, url, image_url, uuid, flag })


//知识库
export const getKnowledgeTable = ({
    source,
    title,
    type,
    label,
    entryType,
    startTime,
    endTime,
    pageSize,
    pageNumber
}) => ajax.post('/repository/list', {
    source,
    title,
    type,
    label,
    entryType,
    startTime,
    endTime,
    pageSize,
    pageNumber
})
export const saveKnowledge = ({
    source,
    entrytype,
    title,
    type,
    describe,
    reason,
    solve,
    image,
    label,
    flag,
    uuid,
    operationsingle,
    proUuid
}) => ajax.post('/repository/save', {
    source,
    entrytype,
    title,
    type,
    describe,
    reason,
    solve,
    image,
    label,
    flag,
    uuid,
    operationsingle,
    proUuid
})

export const isTop = ({ isTop, uuid }) => ajax.post('/repository/isTop', { isTop, uuid })

export const deleteKnow = ({ uuid }) => ajax.post('/repository/delete', { uuid })


//消息管理
export const getMessageTable = ({
    pageSize,
    pageNumber,
    mobile,
    is_success,
    startTime,
    endTime,
    customerType
}) => ajax.post('/message/list', {
    pageSize,
    pageNumber,
    mobile,
    is_success,
    startTime,
    endTime,
    customerType
})
export const sendMsg = ({ customerType, users, title, content }) => ajax.post('/message/send', { customerType, users, title, content })

//用户反馈
export const getFeedbackTable = ({
    pageNumber,
    pageSize,
    name,
    startTime,
    endTime,
    feedbackType,
    state,
    userType
}) => ajax.post('/userfeedback/list', {
    pageNumber,
    pageSize,
    name,
    startTime,
    endTime,
    feedbackType,
    state,
    userType
})

export const confirmPositionErr = ({ inst }) => ajax.post('/userfeedback/save', { inst })
    //export const confirmPositionErr = ({ uuid, name, longitude, latitude, addr }) => ajax.post('/userfeedback/save', { uuid, name, longitude, latitude, addr })
export const cancelPositionErr = ({ uuid }) => ajax.post('/userfeedback/ignore', { uuid })
export const confirmOpinion = ({ uuid }) => ajax.post('/userfeedback/modify', { uuid })

//巡检模板
export const getInspTemp = ({ pageSize, pageNumber }) => ajax.post('/inspectiontemplate/list', { pageSize, pageNumber })

export const changeInsptemp = ({ uuid, name, remark }) => ajax.post('/inspectiontemplate/update', { uuid, name, remark })

//组织机构
//机构管理
export const saveInstInfo = ({
    inst_type,
    parent_uuid,
    name,
    code,
    remark,
    province,
    city,
    district,
    addr,
    longitude,
    latitude,
    uuid,
    flag,
    node_type
}) => ajax.post('/instmanage/save', {
    inst_type,
    parent_uuid,
    name,
    code,
    remark,
    province,
    city,
    district,
    addr,
    longitude,
    latitude,
    uuid,
    flag,
    node_type
})
export const stopInst = ({ uuid, state }) => ajax.post('/instmanage/inactive', { uuid, state })

export const setAss = ({ uuid, assign_mode, assign_to }) => ajax.post('/instmanage/assignSave', { uuid, assign_mode, assign_to })
export const deleteInstMan = ({ uuid }) => ajax.post('/instmanage/delete', { uuid })
export const deleteInstPart = ({ uuid }) => ajax.post('/instmanage/deleteDept', { uuid })


//报修人
export const getRepaireStaffTable = ({
    name,
    notesid,
    inst_uuid,
    province,
    city,
    district,
    startTime,
    endTime,
    auth,
    state,
    customerUuid,
    pageNumber,
    pageSize
}) => ajax.post('/bankcustomer/list', {
    name,
    notesid,
    inst_uuid,
    province,
    city,
    district,
    startTime,
    endTime,
    auth,
    state,
    customerUuid,
    pageNumber,
    pageSize
})
export const deleteReapireStaff = uuid => ajax.post('/bankcustomer/deleted', { uuid })
export const saveRepaireStaff = ({
    uuid,
    notesid,
    name,
    mobile,
    province,
    city,
    district,
    auth_uuid,
    instUuid,
    deptUuid,
    flag
}) => ajax.post('/bankcustomer/save', {
    uuid,
    notesid,
    name,
    mobile,
    province,
    city,
    district,
    auth_uuid,
    instUuid,
    deptUuid,
    flag
})

//待审核报修人
export const getAwaitRepaireTable = ({
    name,
    customerUuid,
    instUuid,
    province,
    city,
    district,
    startTime,
    endTime,
    pageNumber,
    pageSize
}) => ajax.post('/bankcustomer/notApprovedList', {
    name,
    customerUuid,
    instUuid,
    province,
    city,
    district,
    startTime,
    endTime,
    pageNumber,
    pageSize
})
export const examineRepairePeo = ({ uuid, state }) => ajax.post('/bankcustomer/check', { uuid, state })

//服务商架构
export const saveServicePart = ({
    parentUuid,
    name,
    uuid,
    proUuid,
    flag
}) => ajax.post('/servicemanager/save', {
    parentUuid,
    name,
    uuid,
    proUuid,
    flag
})

export const deleteServicePart = instUuid => ajax.post('/servicemanager/delete', { instUuid })


//运维人员
export const saveOneOperator = ({
    uuid,
    name,
    mobile,
    province,
    city,
    district,
    serviceUuid,
    deptUuid,
    iDNumber,
    id_photo_url,
    partner_code
}) => ajax.post('/customermanage/save', {
    uuid,
    name,
    mobile,
    province,
    city,
    district,
    serviceUuid,
    deptUuid,
    iDNumber,
    id_photo_url,
    partner_code
})
export const deleteOneOperator = uuid => ajax.post('/customermanage/delete', { uuid })
export const relieveRele = uuid => ajax.post('/customermanage/deletecustomer ', { uuid })
export const releCus = (user_uuid, partnerCode) => ajax.post('/customermanage/saveCustomer', { user_uuid, partnerCode })

//待审核运维
export const examineProPeo = ({ uuid, decline }) => ajax.post('/reportermanage/approve', { uuid, decline })
    //应急分组
export const deleteEmergroup = uuid => ajax.post('/urgentGroup/delete', { uuid })
export const saveEmerGroup = ({
    uuid,
    customer_uuid,
    name,
    member_uuids
}) => ajax.post('/urgentGroup/save', {
    uuid,
    customer_uuid,
    name,
    member_uuids
})

//设备列表
export const saveEquip = ({
    uuid,
    customerUuid,
    instUuid,
    deptUuid,
    bussinesUuid,
    typeCdUuid,
    name,
    brand,
    purchaseDate,
    amt,
    sn,
    assets_code,
    receiptor,
    receipt_time,
    ip,
    mac,
    facilitator,
    facilitator_tel,
    remark
}) => ajax.post('/equip/save', {
    uuid,
    customerUuid,
    instUuid,
    deptUuid,
    bussinesUuid,
    typeCdUuid,
    name,
    brand,
    purchaseDate,
    amt,
    sn,
    assets_code,
    receiptor,
    receipt_time,
    ip,
    mac,
    facilitator,
    facilitator_tel,
    remark
})
export const saveTransfer = ({ uuid, inst, department }) => ajax.post('/equip/circUpdate', { uuid, inst, department })
export const scrapEquip = (uuid, instUuid, iname, flag) => ajax.post('/equip/freezon', { uuid, instUuid, iname, flag })
export const deleteEquip = uuid => ajax.post('/equip/delete', { uuid })
export const plxzEquips = ({ instUuid, bussines, type_cd, numbers }) => ajax.post('/equip/equipsSave', { instUuid, bussines, type_cd, numbers })

//设备类型
export const saveSupType = ({ uuid, name }) => ajax.post('/equipType/save', { parentids: '', uuid, name, status: 'y' })
export const deleteSupType = uuid => ajax.post('/equipType/delete', { uuid, status: 'y' })
export const saveSubType = ({ uuid, name, parentids }) => ajax.post('/equipType/save', { uuid, name, parentids, status: 'n' })
export const deleteSubType = uuid => ajax.post('/equipType/delete', { uuid, status: 'n' })